/***************************************************************************
 *   Copyright (C) 2009 by Marcin Swiechowicz   *
 *   marcin.swiechowicz@gmail.com   *
 *                                                                         *
 *   This program is free software; you can redistribute it and/or modify  *
 *   it under the terms of the GNU General Public License as published by  *
 *   the Free Software Foundation; either version 2 of the License, or     *
 *   (at your option) any later version.                                   *
 *                                                                         *
 *   This program is distributed in the hope that it will be useful,       *
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
 *   GNU General Public License for more details.                          *
 *                                                                         *
 *   You should have received a copy of the GNU General Public License     *
 *   along with this program; if not, write to the                         *
 *   Free Software Foundation, Inc.,                                       *
 *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
 ***************************************************************************/
#ifndef KDCLIB_H
#define KDCLIB_H

#include "kdcnamespace.h"
#include <kdcobject.h>
#include <kdcdisc.h>
#include <kdcmovie.h>
#include <kdcvts.h>
#include <QString>

bool isNull( void *ptr );
void deletePtr( void *aPtr );
QString toString( KDC::VideoCodec codec );
QString toString( KDC::AudioCodec codec );
QString toString( KDC::AspectRatio ar );
QString toString( KDC::VideoFormat format );
QString toString( KDC::Demuxer demuxer );
QString toString( KDC::StreamMode mode );
QString toString( KDC::DiscType type );
QString bitrateAsString( int bitrate );

KDC::AspectRatio aspectRatio(	KDC::DiscType type, double ar, int width, int height, KDC::VideoCodec codec );
bool isInRange( int value, int min, int max );
bool isInRange( double value, double min, double max );
	
bool isPALDVDResolution( int width, int height );
bool isNTSCDVDResolution( int width, int height );
int getCorrectHeight( int width, int oldHeight, KDC::VideoFormat format );

bool createDirectory( const QString& path );
void removeDirectory( const QString& path );
bool removeFile( const QString& path );
bool renameFile( const QString& oldName , const QString& newName );

QString mountPoint( const QString& path );

QString readAll( const QString& fileName );
void writeToFile( const QString& fileName, const char *msg, bool append = TRUE );
QString fileName( const QString& path );
QString baseFileName( const QString& path );
QString filePath( const QString& path );
QString fileNameWithoutExtension( const QString& path );

KDCDisc* getDisc( KDCObject *aObject );
KDCVTS* getVTS( KDCObject *aObject );
QString movieNameFromPos( KDCMovie *aMovie, int aPos );
int moviePos( KDCMovie *aMovie, int aPos );
QString applicationDataDir();

#endif
